import java.util.*;

public class Practice2 {
    //一道滑动窗口
    //https://www.nowcoder.com/practice/e8480ed7501640709354db1cc4ffd42a?tpId=37&tqId=21286&ru=/exam/oj
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        String s = in.next();
        char[] ss = s.toCharArray();
        int n = in.nextInt();
        int countMax = 0;//计算最大gc数
        int index = 0;//存储最大左下标
        int left = 0;
        int count = 0;//统计gc数
        //双指针直接套模板, 进窗口, 判断, 出窗口
        for(int right = 0;right < ss.length;right++){
            if(ss[right] == 'G' || ss[right] == 'C'){
                count++;
            }
            if(right - left + 1 == n){
                if(countMax < count){
                    countMax = Math.max(countMax,count);
                    index = left;
                }
                if(ss[left] == 'G' || ss[left] == 'C'){
                    count--;
                }
                left++;
            }
        }
        System.out.println(s.substring(index,index + n));
    }
}
